package com.clear.honghefinance.common.exception;

import com.clear.honghefinance.common.enums.ApiResponseCodeEnum;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

@Getter
@Setter
public class ParameterException extends BaseException {

    /**
     * 错误码
     */
    private Integer code;

//    /**
//     * 错误提示
//     */
//    private String message;

    private Map<String, String> fieldErrors;


    public ParameterException(String message) {
        super(ApiResponseCodeEnum.PARAMETER_INVALID.getCode(), message);
    }

    public ParameterException(String message, Throwable t) {
        super(message, t);
    }

    public ParameterException(int code, String message) {
        super(code, message);
    }

    public ParameterException(Map<String, String> fieldErrors) {
        super(ApiResponseCodeEnum.PARAMETER_INVALID.getCode(), ApiResponseCodeEnum.PARAMETER_INVALID.getMessage());
        this.fieldErrors = fieldErrors;
    }

    public ParameterException(String key, String value) {
        super(ApiResponseCodeEnum.PARAMETER_INVALID.getCode(), ApiResponseCodeEnum.PARAMETER_INVALID.getMessage());
        Map<String, String> fieldErrors = new HashMap<>();
        fieldErrors.put(key, value);
        this.fieldErrors = fieldErrors;
    }


}
